package com.merlin.meta.app.controller;

import java.util.List;
import java.util.Map;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.merlin.framework.core.bean.PageBean;
import com.merlin.framework.core.bean.Result;
import com.merlin.framework.core.label.InterfaceApiLabel;
import com.merlin.meta.app.service.MetaDomainService;
import com.merlin.meta.app.vo.MetaDomainAddVo;
import com.merlin.meta.app.vo.MetaDomainUpdateVo;
import com.merlin.meta.app.vo.MetaDomainVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/metaapp")
@Api(description = "元数据应用服务的API接口")
	/**
	 * 
	* @ClassName:：MetaDomainController 
	* @Description：元数据领域事件中心
	* @author ：张海滨(merlin)
	* @date ：2019年11月18日 上午11:32:12 
	*
	 */
public class MetaDomainController {
	@Autowired
	private MetaDomainService metaDomainService;
	/**
	 * 
	* @Title：searchDomains 
	* @Description：领域信息列表查询
	* @param ：@param pageBean
	* @param ：@param headers
	* @param ：@return 
	* @return ：Result<List<MetaDomainVo>> 
	* @throws
	 */
	@ApiOperation(value = "app_meta_domain_0001-领域信息列表查询", notes = "领域信息列表查询")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "Authorization", value = "新式令牌", required = false, dataType = "String", paramType = "header"),
		@ApiImplicitParam(name = "Merlin_BUSINESS_SERIALID", value = "交易流水", required = false, dataType = "String", paramType = "header",defaultValue="35535cc7-5037-11e7-b2ef-5254f7f2fbdd"),
		@ApiImplicitParam(name = "Merlin_REQUEST_SYS_CODE", value = "请求方系统编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_MODULE_CODE", value = "请求方模块编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_NODE_IP", value = "请求方节点IP", required = false, dataType = "String", paramType = "header",defaultValue="219.142.80.211"),
		@ApiImplicitParam(name = "Accept", value = "接收属性", required = true,dataType="String",paramType="header",defaultValue="application/json"),
		@ApiImplicitParam(name = "Accept-Charset", value = "接收字符集", required = true,dataType="String",paramType="header",defaultValue="utf-8"),
		@ApiImplicitParam(name = "Content-Type", value = "内容类型", required = true,dataType="String",paramType="header",defaultValue="application/json; charset=UTF-8")
	})
	@RequestMapping(value = "/domains", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@InterfaceApiLabel(value = "app_meta_domain_0001", description = "领域信息列表查询")
	public Result<List<MetaDomainVo>> searchDomains(PageBean pageBean, @RequestHeader HttpHeaders headers) {

		Result<List<MetaDomainVo>> result = metaDomainService.searchDomains(pageBean, headers);
		return result;
	}

    /**
     * 
    * @Title：getMaster 
    * @Description：领域信息单记录查询
    * @param ：@param code
    * @param ：@param headers
    * @param ：@return 
    * @return ：Result<MetaDomainVo> 
    * @throws
     */
	@ApiOperation(value = "app_meta_domain_0002-领域信息单记录查询", notes = "领域信息单记录查询")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "code", value = "编码", required = true, dataType = "String", paramType = "path"),
		@ApiImplicitParam(name = "Authorization", value = "新式令牌", required = false, dataType = "String", paramType = "header"),
		@ApiImplicitParam(name = "Merlin_BUSINESS_SERIALID", value = "交易流水", required = false, dataType = "String", paramType = "header",defaultValue="35535cc7-5037-11e7-b2ef-5254f7f2fbdd"),
		@ApiImplicitParam(name = "Merlin_REQUEST_SYS_CODE", value = "请求方系统编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_MODULE_CODE", value = "请求方模块编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_NODE_IP", value = "请求方节点IP", required = false, dataType = "String", paramType = "header",defaultValue="219.142.80.211"),
		@ApiImplicitParam(name = "Accept", value = "接收属性", required = true,dataType="String",paramType="header",defaultValue="application/json"),
		@ApiImplicitParam(name = "Accept-Charset", value = "接收字符集", required = true,dataType="String",paramType="header",defaultValue="utf-8"),
		@ApiImplicitParam(name = "Content-Type", value = "内容类型", required = true,dataType="String",paramType="header",defaultValue="application/json; charset=UTF-8")
	})
	@RequestMapping(value = "/domain/{code}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
	@InterfaceApiLabel(value = "app_meta_domain_0002", description = "领域信息单记录查询")
	public Result<MetaDomainVo> getMaster(@PathVariable String code,@RequestHeader HttpHeaders headers) {
		Result<MetaDomainVo> result = metaDomainService.getDomain(code, headers);
		return result;
	}

    /**
     * 
    * @Title：deleteDomain 
    * @Description：领域信息删除
    * @param ：@param code
    * @param ：@param headers
    * @param ：@return 
    * @return ：Result<String> 
    * @throws
     */
	@ApiOperation(value = "app_meta_domain_0003-领域信息删除", notes = "领域信息删除")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "code", value = "编码", required = true, dataType = "String", paramType = "path"),
		@ApiImplicitParam(name = "Authorization", value = "新式令牌", required = false, dataType = "String", paramType = "header"),
		@ApiImplicitParam(name = "Merlin_BUSINESS_SERIALID", value = "交易流水", required = false, dataType = "String", paramType = "header",defaultValue="35535cc7-5037-11e7-b2ef-5254f7f2fbdd"),
		@ApiImplicitParam(name = "Merlin_REQUEST_SYS_CODE", value = "请求方系统编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_MODULE_CODE", value = "请求方模块编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_NODE_IP", value = "请求方节点IP", required = false, dataType = "String", paramType = "header",defaultValue="219.142.80.211"),
		@ApiImplicitParam(name = "Accept", value = "接收属性", required = true,dataType="String",paramType="header",defaultValue="application/json"),
		@ApiImplicitParam(name = "Accept-Charset", value = "接收字符集", required = true,dataType="String",paramType="header",defaultValue="utf-8"),
		@ApiImplicitParam(name = "Content-Type", value = "内容类型", required = true,dataType="String",paramType="header",defaultValue="application/json; charset=UTF-8")
	})
	@RequestMapping(value = "/domain/{code}", method = RequestMethod.DELETE, produces = "application/json;charset=UTF-8")
	@InterfaceApiLabel(value = "app_meta_domain_0003", description = "领域信息删除")
	public Result<String> deleteDomain(@PathVariable String code,@RequestHeader HttpHeaders headers) {
		Result<String> result = metaDomainService.deleteDomain(code, headers);
		return result;
	}

	  /**
	   * 
	  * @Title：createDomain 
	  * @Description：领域信息创建
	  * @param ：@param metaDomainAddVo
	  * @param ：@param bindingResult
	  * @param ：@param headers
	  * @param ：@return 
	  * @return ：Result<String> 
	  * @throws
	   */

	@ApiOperation(value = "app_meta_domain_0004-领域信息创建", notes = "领域信息创建")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "Authorization", value = "新式令牌", required = false, dataType = "String", paramType = "header"),
		@ApiImplicitParam(name = "metaDomainAddVo", value = "领域新增VO", required = true,dataType="MetaDomainAddVo",paramType="body"),
		@ApiImplicitParam(name = "Merlin_BUSINESS_SERIALID", value = "交易流水", required = false, dataType = "String", paramType = "header",defaultValue="35535cc7-5037-11e7-b2ef-5254f7f2fbdd"),
		@ApiImplicitParam(name = "Merlin_REQUEST_SYS_CODE", value = "请求方系统编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_MODULE_CODE", value = "请求方模块编码", required = false, dataType = "String", paramType = "header",defaultValue="swagger"),
		@ApiImplicitParam(name = "Merlin_REQUEST_NODE_IP", value = "请求方节点IP", required = false, dataType = "String", paramType = "header",defaultValue="219.142.80.211"),
		@ApiImplicitParam(name = "Accept", value = "接收属性", required = true,dataType="String",paramType="header",defaultValue="application/json"),
		@ApiImplicitParam(name = "Accept-Charset", value = "接收字符集", required = true,dataType="String",paramType="header",defaultValue="utf-8"),
		@ApiImplicitParam(name = "Content-Type", value = "内容类型", required = true,dataType="String",paramType="header",defaultValue="application/json; charset=UTF-8")
	})
	@RequestMapping(value = "/domain", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	@InterfaceApiLabel(value = "app_meta_domain_0004", description = "领域信息创建")
	public Result<String> createDomain(@Valid @RequestBody MetaDomainAddVo metaDomainAddVo,
			BindingResult bindingResult, @RequestHeader HttpHeaders headers) {
		Result<String> result = metaDomainService.createDomain(metaDomainAddVo, headers);
		return result;
	}

	/**
	 * 
	* @Title：alterDomain 
	* @Description：领域信息修改
	* @param ：@param metaDomainUpdateVo
	* @param ：@param bindingResult
	* @param ：@param headers
	* @param ：@return 
	* @return ：Result<String> 
	* @throws
	 */
	@ApiOperation(value = "app_meta_domain_0005-领域信息修改", notes = "领域信息修改")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "Authorization", value = "新式令牌", required = false, dataType = "String", paramType = "header"),
			@ApiImplicitParam(name = "metaDomainUpdateVo", value = "领域更新VO", required = true,dataType="MetaDomainUpdateVo",paramType="body"),
			@ApiImplicitParam(name = "code", value = "编码", required = false, dataType = "String", paramType = "path"),
			@ApiImplicitParam(name = "TK_BUSINESS_SERIALID", value = "交易流水", required = true, dataType = "String", paramType = "header", defaultValue = "0035d7cba33f43349fc1498c64275670"),
			@ApiImplicitParam(name = "TK_REQUEST_SYS_CODE", value = "请求方系统编码", required = true, dataType = "String", paramType = "header", defaultValue = "swagger"),
			@ApiImplicitParam(name = "TK_REQUEST_MODULE_CODE", value = "请求方模块编码", required = true, dataType = "String", paramType = "header", defaultValue = "swagger"),
			@ApiImplicitParam(name = "TK_REQUEST_NODE_IP", value = "请求方节点IP", required = true, dataType = "String", paramType = "header", defaultValue = "219.142.80.211"),
			@ApiImplicitParam(name = "Accept", value = "接收属性", required = true, dataType = "String", paramType = "header", defaultValue = "application/json"),
			@ApiImplicitParam(name = "Accept-Charset", value = "接收字符集", required = true, dataType = "String", paramType = "header", defaultValue = "utf-8"),
			@ApiImplicitParam(name = "Content-Type", value = "内容类型", required = true, dataType = "String", paramType = "header", defaultValue = "application/json; charset=UTF-8") })
	@RequestMapping(value = "/domain/{code}", method = RequestMethod.PUT, produces = "application/json;charset=UTF-8")
	@InterfaceApiLabel(value = "app_meta_domain_0005", description = "领域信息修改")
	public Result<String> alterDomain(@Valid @RequestBody MetaDomainUpdateVo metaDomainUpdateVo,BindingResult bindingResult, @RequestHeader HttpHeaders headers) {
		Result<String> result = metaDomainService.alterDomain(metaDomainUpdateVo, headers);
		return result;
	}

}
